// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "ActiveGameplayEffectHandle.h"
#include "GameFramework/Actor.h"
#include "EffectActorBase.generated.h"

class UAbilitySystemComponent;
class UGameplayEffect;


/**
 * 效果应用策略枚举: 什么时候应用效果
 * BlueprintType: 蓝图变量可用的类型
 * enum class : 作用域枚举
 */
UENUM(BlueprintType)
enum class EEffectApplicationPolicy: uint8
{
	ApplyOnOverlap,
	ApplyOnEndOverlap,
	DoNotApply //不做应用
};

/**
 * 效果移除策略: 什么时候移除效果
 */
UENUM()
enum class EEffectRemovalPolicy
{
	RemoveOnEndOverlap,
	DoNotRemove, //不做移除
};

UCLASS()
class AURA_API AEffectActorBase : public AActor
{
	GENERATED_BODY()

public:

	AEffectActorBase();

protected:

	// ----------------------------------------------------------------------------------------------------------------
	//	InstantGE
	// ----------------------------------------------------------------------------------------------------------------

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	TSubclassOf<UGameplayEffect> InstantGameplayEffectClass;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	EEffectApplicationPolicy InstantEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;

	// ----------------------------------------------------------------------------------------------------------------
	//	DurationGE
	// ----------------------------------------------------------------------------------------------------------------

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	TSubclassOf<UGameplayEffect> DurationGameplayEffectClass;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	EEffectApplicationPolicy DurationEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;

	// ----------------------------------------------------------------------------------------------------------------
	//	InfinityGE
	// ----------------------------------------------------------------------------------------------------------------

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	TSubclassOf<UGameplayEffect> InfinityGameplayEffectClass;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	EEffectApplicationPolicy InfinityEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;

	/** InfinityGE默认移除策略: 结束重叠时 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	EEffectRemovalPolicy InfinityEffectRemovalPolicy = EEffectRemovalPolicy::RemoveOnEndOverlap;

	// ----------------------------------------------------------------------------------------------------------------
	//	
	// ----------------------------------------------------------------------------------------------------------------

	TMap<FActiveGameplayEffectHandle, UAbilitySystemComponent*> ActiveEffectToRemove;

	/** 生成效果的等级 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Apply Effect")
	float EffectSpecLevel = 1.f;

	/** GE在应用后，此物体是否需要被销毁 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Apply Effects")
	bool bDestroyOnEffectApplication = true;
	
	/** 敌人是否能够拾取此物体 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Apply Effects")
	bool bCanApplyEffectToEnemy = false;
	
	/* 蓝图->应用效果到目标Actor */
	UFUNCTION(BlueprintCallable)
	void ApplyEffectToTarget(AActor* TargetActor, TSubclassOf<UGameplayEffect> ApplyGameplayEffectClass);

	/* 蓝图调用->处理重叠 */
	UFUNCTION(BlueprintCallable)
	void HandleOverlay(AActor* TargetActor);

	/* 蓝图调用->处理结束重叠 */
	UFUNCTION(BlueprintCallable)
	void HandleEndOverlap(AActor* TargetActor);
};
